package com.ds.infrastructure.hyperspace.container.internal.operator;

import com.ds.infrastructure.hyperspace.common.Operator;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;

/**
 * @author  Weishaoying
 */
@Slf4j
@Getter
public class OperatorDefinition {

    private final String operatorName;

    private final String[] operatorArgs;

    private final String[] preparedOperatorArgs;

    private final Operator operator;

    public OperatorDefinition(String operatorName, String[] operatorArgs, Operator operator) {
        this.operatorName = operatorName;
        this.operatorArgs = operatorArgs;
        this.preparedOperatorArgs = operator.prepareArgs(operatorArgs);
        this.operator = operator;
    }

    public String compute(String inputValue) {
        return operator.compute(inputValue, preparedOperatorArgs);
    }
}
